import { AuthService } from './auth.service';
import { Injectable } from "@nestjs/common";
import { PassportStrategy } from '@nestjs/passport';
import { Strategy } from "passport-local";

@Injectable()
export class LocalStrategy extends PassportStrategy(Strategy) {
    constructor(private readonly authServ:AuthService){
        super();
    } 
 
    /**
     * 本地策略的 validate可以不做任何处理，交由对应的登录接口进行细致处理
     */
    async validate(username:string, password:string):Promise<any> {
        console.log('本地策略')
        // const user = await this.authServ.validateUser(username,password);
        // console.log("🚀 ~ file: local.strategy.ts ~ line 15 ~ LocalStrategy ~ validate ~ user", user)
        // if(!user) {
        //     return new UnauthorizedException();
        // }
        // return user;
        return true
    }
}